#include "MenuPanel.h"

//=====CONSTRUCTORS
MenuPanel::MenuPanel()
	:Drawable(0,0,1,1,TYPE_MENUPANEL,TEX_MENUPANEL),
	m_bisActive(false),
	m_eiShowCondition(0),
	RelatedID(-1),
	m_sMenuName("")
{}
MenuPanel::MenuPanel(float X, float Y,float scaX, float scaY, int Show,int TypeID, string Text)
	:Drawable(X,Y,scaX,scaY,TYPE_MENUPANEL,TEX_MENUPANEL),
	m_bisActive(false),
	RelatedID(TypeID),
	m_eiShowCondition(Show),
	m_sMenuName(Text)
{}
//=====INITIALIZE
void MenuPanel::Initialize(LPDIRECT3DTEXTURE9 T)
{
	D3DSURFACE_DESC Dimensions;
	T->GetLevelDesc(0,&Dimensions);

	float X = Dimensions.Width ; //* 0.5f;
	float Y = Dimensions.Height;// * 0.5f;
	//TODO: FIND THE PROPER OFFSET FOR THE TEXT BOX
	//Chooses the location based off (Position +- (textureMeasure/2 * objectScale))
	
	TextLocation.left 	= (long)(m_vecPosition.x - (X * m_vecScale.x));
	TextLocation.right 	= (long)(m_vecPosition.x + (X * m_vecScale.x));
	TextLocation.top 	= (long)(m_vecPosition.y - (Y * m_vecScale.y));
	TextLocation.bottom = (long)(m_vecPosition.y + (Y * m_vecScale.y));
}
//=====UPDATE
void MenuPanel::Update()
{
	if(m_eiShowCondition == GS_ALWAYS)			m_bisActive = true;
	if(m_eiShowCondition == c_eiGameState)		m_bisActive = true;
	if(m_eiShowCondition != GS_ALWAYS 
		&& m_eiShowCondition != c_eiGameState)	m_bisActive = false;
}
//=====ACCESSORS
bool MenuPanel::isActive()	//Whether or not the element should be interactable and visible
{
	if(m_eiShowCondition == c_eiGameState || m_eiShowCondition == GS_ALWAYS)
		return true;
	if(m_bisActive)
		return true;
	return false;
}
//=======MUTATORS
void MenuPanel::UpdateTextFor(Zone* Z)
{
	if(Z->GetID() == this->RelatedID)
		Z->UpdateOutputText(m_sContent);
}
void MenuPanel::ModifyContent(string NewText)
{
	m_sContent = NewText;
}
